//
//  MMCapture.h
//  MemeMaker
//
//  Created by dangthan on 7/30/13.
//  Copyright (c) 2013 soyo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>

@protocol MMCaptureDelegate;

@interface MMCapture : NSObject {
    AVCaptureSession *capSession;
    AVCaptureDeviceInput *vInput;
    
    AVCaptureStillImageOutput *stillImageOutput;
}

@property (nonatomic, assign) id<MMCaptureDelegate> delegate;
@property (nonatomic, readonly, strong) AVCaptureSession *capSession;
@property (nonatomic, readonly, strong) AVCaptureDeviceInput *vInput;
@property (nonatomic, assign) AVCaptureFlashMode flash;
@property (nonatomic, assign) AVCaptureTorchMode torch;
@property (nonatomic, assign) AVCaptureFocusMode focus;
@property (nonatomic, assign) AVCaptureExposureMode exposure;
@property (nonatomic, assign) AVCaptureWhiteBalanceMode whiteBalance;

- (BOOL)setupSessionWithPreset:(NSString *)sessionPreset error:(NSError **)error;
- (void)startRunning;
- (void)stopRunning;
- (NSUInteger)cameraCount;
- (void)captureStillImage;
- (BOOL)cameraToggleClicked;
- (BOOL)hasMultipleCameras;
- (BOOL)hasFlash;
- (BOOL)hasTorch;
- (BOOL)hasFocus;
- (BOOL)hasExposure;
- (BOOL)hasWhiteBalance;
- (void)focusAtPoint:(CGPoint)point;
- (void)exposureAtPoint:(CGPoint)point;
+ (AVCaptureConnection *)connectionWithMediaType:(NSString *)mediaType fromConnections:(NSArray *)connections;

@end

@protocol MMCaptureDelegate<NSObject>
@optional
- (void)captureSessionDidStartRunning;
- (void)captureStillImageFinished:(UIImage *)image;
- (void)captureStillImageFailedWithError:(NSError *)error;
- (void)acquiringDeviceLockFailedWithError:(NSError *)error;
- (void)cannotWriteToAssetLibrary;
- (void)assetLibraryError:(NSError *)error forURL:(NSURL *)assetURL;
- (void)someOtherError:(NSError *)error;

@end
